css: Don't print numbers with exponent
authorBenjamin Otte <otte@redhat.com>
Wed, 29 May 2019 04:48:03 +0000 (06:48 +0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 29 May 2019 05:14:31 +0000 (07:14 +0200)
CSS does not do exponents, so printing numbers close to 0 as 1.234e-15
does not work.

Also up the accuracy to 17 digits because that's what everyone else
uses.

gdk/gdkrgba.c
gsk/gskrendernodeparser.c
gtk/css/gtkcsstokenizer.c
gtk/gtkcssdimensionvalue.c

index b52e0254e6f101f4419fe0da99cb4dcaead80909..a9b9365e0e899385e0392f42847e466ba6789058 100644 (file)
@@ -386,7 +386,7 @@ gdk_rgba_to_string (const GdkRGBA *rgba)
     {
       gchar alpha[G_ASCII_DTOSTR_BUF_SIZE];
 
-      g_ascii_formatd (alpha, G_ASCII_DTOSTR_BUF_SIZE, "%g", CLAMP (rgba->alpha, 0, 1));
+      g_ascii_formatd (alpha, G_ASCII_DTOSTR_BUF_SIZE, "%.17f", CLAMP (rgba->alpha, 0, 1));
 
       return g_strdup_printf ("rgba(%d,%d,%d,%s)",
                               (int)(0.5 + CLAMP (rgba->red, 0., 1.) * 255.),
index 937e7d796ffd8ef13f6ae981d4f8b0770ab4c631..428394bbb17bd19a8b38a419e188599c7dd726bb 100644 (file)
@@ -1510,7 +1510,7 @@ string_append_double (GString *string,
 {
   char buf[G_ASCII_DTOSTR_BUF_SIZE];
 
-  g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%g", d);
+  g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%.17f", d);
   g_string_append (string, buf);
 }
 
index c9a38566574b6ee636f05fae8e56f5526179d37b..a9cab554a3cf61333061def744bb055fc59f7c01 100644 (file)
@@ -406,7 +406,7 @@ gtk_css_token_print (const GtkCssToken *token,
       /* fall through */
     case GTK_CSS_TOKEN_SIGNLESS_INTEGER_DIMENSION:
     case GTK_CSS_TOKEN_DIMENSION:
-      g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, token->dimension.value);
+      g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%.17f", token->dimension.value);
       g_string_append (string, buf);
       append_ident (string, token->dimension.dimension);
       break;
index 4efdf13ef269546715054ccd5631b7d45fc58f90..626c0ac2cb128df1f874407def467ec3c7262b4f 100644 (file)
@@ -198,7 +198,7 @@ gtk_css_value_dimension_print (const GtkCssValue *number,
     g_string_append (string, "infinite");
   else
     {
-      g_ascii_dtostr (buf, sizeof (buf), number->value);
+      g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%.17f", number->value);
       g_string_append (string, buf);
       if (number->value != 0.0)
         g_string_append (string, names[number->unit]);